/*
 * AirplanesUI.java
 *
 * Created on 09/10/2011, 20:08:39
 */
package com.bcc.airlines.ui;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;

import com.bcc.airlines.app.Facade;
import com.bcc.airlines.domain.Aeronave;
import com.bcc.airlines.domain.Companhia;
import com.bcc.airlines.domain.Tripulante;
import com.bcc.airlines.patterns.Observador;
import com.bcc.airlines.ui.effects.TextFieldEffects;
import com.bcc.airlines.util.Tupla;



/**
 *
 * @author Serginho
 */
public class AirplanesUI extends javax.swing.JPanel implements Observador {

    public AirplanesUI(MainUI main) {
        this.main = main;
        initComponents();
        atualiza();
    }

    @Override
    public void atualiza() {
        updateAirplanesTable();
        updateTripulationTable();
    }

    /**
     * Atualiza a tabela de aeronaves
     */
    private void updateAirplanesTable() {
        Facade fachada = main.getFachada();
        List<Aeronave> airplanes = fachada.<Aeronave>list(Aeronave.class);

        // Pega o modelo da tabela que atualiza os dados
        DefaultTableModel model = (DefaultTableModel) airplanesTable.getModel();

        // Apaga tudinho
        for (int i = model.getRowCount() - 1; i >= 0; i--) {
            model.removeRow(i);
        }

        if (airplanes != null && !airplanes.isEmpty()) {
            for (Aeronave a : airplanes) {
                Object row[] = new Object[1];
                row[0] = a.getNome();
                model.addRow(row);
            }
        }

        clearFields();
    }

    /**
     * Adiciona uma aeronave
     */
    private void submitAirplane() {
        Companhia companhia = new Companhia(1, "BCC Airlines", null, null);
        Facade fachada = main.getFachada();

        String id = airplaneIDTextField.getText().trim();
        String model = airplaneModelTextField.getText().trim();
        Aeronave a = new Aeronave(0, companhia, model, 0, null, null, null);

        fachada.<Aeronave>add(Aeronave.class, a);

        updateAirplanesTable();
    }

    /**
     * Remove uma aeronave
     */
    private void removeAirplane() {
        Facade fachada = main.getFachada();
        TableModel model = airplanesTable.getModel();

        // Pega o numero da ID na tabela
        int linha = airplanesTable.getSelectedRow();
        String id = (String) model.getValueAt(linha, 0);

        // Procura pelo elemento a ser removido no banco
        Aeronave a = fachada.<Aeronave>get(Aeronave.class, id);

        // Remove o elemento do banco
        fachada.<Aeronave>remove(Aeronave.class, a);

        updateAirplanesTable();
    }

    /**
     * Atualiza a tabela de tripulacao
     */
    private void updateTripulationTable() {
        Facade fachada = main.getFachada();
        List<Tripulante> tripulantes = fachada.<Tripulante>list(Tripulante.class);

        // Pega o modelo da tabela que atualiza os dados
        DefaultTableModel model = (DefaultTableModel) tripulationTable.getModel();

        // Apaga tudinho
        for (int i = model.getRowCount() - 1; i >= 0; i--) {
            model.removeRow(i);
        }

        // Coloca dados fresquinhos
        if (tripulantes != null && !tripulantes.isEmpty()) {
            for (Tripulante t : tripulantes) {
                Object row[] = new Object[2];
                row[0] = t.getNome();
                model.addRow(row);
            }
        }

        clearFields();
    }

    /**
     * Adiciona um tripulante
     */
    private void submitTripulante() {
        Facade fachada = main.getFachada();

        String nome = tripulanteNameTextField.getText().trim();
        String cargo = String.valueOf((String) cargoComboBox.getSelectedItem());

        Tripulante t = new Tripulante(0, null, nome, cargo);

        fachada.<Tripulante>add(Tripulante.class, t);

        updateTripulationTable();
    }

    /**
     * Remove um tripulante
     */
    private void removeTripulante() {
        Facade fachada = main.getFachada();
        TableModel model = tripulationTable.getModel();

        // Pega o numero da ID na tabela
        int linha = tripulationTable.getSelectedRow();
        String name = (String) model.getValueAt(linha, 0);

        // Procura pelo elemento a ser removido no banco
        Tripulante t = fachada.<Tripulante>get(Tripulante.class, name);

        // Remove o elemento do banco
        fachada.<Tripulante>remove(Tripulante.class, t);

        updateTripulationTable();
    }

    /**
     * O nome j� diz, pelamordedeus
     */
    private void clearFields() {
        List<Tupla<JTextField, String>> campos = new ArrayList<>();
        campos.add(new Tupla<>(airplaneIDTextField, airplaneIDMessage));
        campos.add(new Tupla<>(airplaneModelTextField, airplaneModelMessage));
        campos.add(new Tupla<>(tripulanteNameTextField, tripulanteNameMessage));

        // Manda essa classe fazer o trabalho grosso.
        TextFieldEffects.clearFields(campos);
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        titleLabel = new javax.swing.JLabel();
        quitLabel = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        airplaneModelTextField = new javax.swing.JTextField();
        airplaneIDTextField = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        airplanesTable = new javax.swing.JTable();
        jLabel3 = new javax.swing.JLabel();
        removeAirplaneLabel = new javax.swing.JLabel();
        saveAirplaneLabel = new javax.swing.JLabel();
        updateAirplaneTableLabel = new javax.swing.JLabel();
        jPanel3 = new javax.swing.JPanel();
        tripulanteNameTextField = new javax.swing.JTextField();
        removeTripulanteLabel = new javax.swing.JLabel();
        saveTripulanteLabel = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        tripulationTable = new javax.swing.JTable();
        jLabel4 = new javax.swing.JLabel();
        cargoComboBox = new javax.swing.JComboBox();
        updateTripulationTable = new javax.swing.JLabel();

        setBackground(new java.awt.Color(58, 58, 58));

        jPanel1.setBackground(new java.awt.Color(160, 160, 160));

        titleLabel.setFont(new java.awt.Font("Lucida Sans", 1, 16)); // NOI18N
        titleLabel.setForeground(new java.awt.Color(255, 255, 255));
        titleLabel.setText("Aeronaves e Tripulantes");

        quitLabel.setFont(new java.awt.Font("Lucida Sans", 1, 16));
        quitLabel.setForeground(new java.awt.Color(255, 255, 255));
        quitLabel.setText("X");
        quitLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                quitLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                quitLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                quitLabelMouseExited(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1Layout.createSequentialGroup()
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .add(titleLabel)
                .add(57, 57, 57)
                .add(quitLabel)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                .add(quitLabel)
                .add(titleLabel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
        );

        jPanel2.setOpaque(false);

        airplaneModelTextField.setForeground(new java.awt.Color(119, 167, 243));
        airplaneModelTextField.setText("Modelo");
        airplaneModelTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                airplaneModelTextFieldFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                airplaneModelTextFieldFocusLost(evt);
            }
        });

        airplaneIDTextField.setForeground(new java.awt.Color(119, 167, 243));
        airplaneIDTextField.setText("ID");
        airplaneIDTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                airplaneIDTextFieldFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                airplaneIDTextFieldFocusLost(evt);
            }
        });

        airplanesTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Identifica��o", "Modelo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane1.setViewportView(airplanesTable);

        jLabel3.setFont(new java.awt.Font("Lucida Sans", 2, 16));
        jLabel3.setForeground(new java.awt.Color(255, 255, 255));
        jLabel3.setText("Aeronaves");

        removeAirplaneLabel.setForeground(new java.awt.Color(255, 255, 255));
        removeAirplaneLabel.setText("Remover");
        removeAirplaneLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                removeAirplaneLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                removeAirplaneLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                removeAirplaneLabelMouseExited(evt);
            }
        });

        saveAirplaneLabel.setForeground(new java.awt.Color(255, 255, 255));
        saveAirplaneLabel.setText("Salvar");
        saveAirplaneLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveAirplaneLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                saveAirplaneLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                saveAirplaneLabelMouseExited(evt);
            }
        });

        updateAirplaneTableLabel.setForeground(new java.awt.Color(255, 255, 255));
        updateAirplaneTableLabel.setText("Atualizar");
        updateAirplaneTableLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                updateAirplaneTableLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                updateAirplaneTableLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                updateAirplaneTableLabelMouseExited(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel2Layout = new org.jdesktop.layout.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 368, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jLabel3)
                    .add(jPanel2Layout.createSequentialGroup()
                        .add(saveAirplaneLabel)
                        .add(18, 18, 18)
                        .add(removeAirplaneLabel)
                        .add(18, 18, 18)
                        .add(updateAirplaneTableLabel))
                    .add(airplaneIDTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(airplaneModelTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel3)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jPanel2Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(saveAirplaneLabel)
                    .add(removeAirplaneLabel)
                    .add(updateAirplaneTableLabel))
                .add(18, 18, 18)
                .add(airplaneIDTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(airplaneModelTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel3.setOpaque(false);

        tripulanteNameTextField.setForeground(new java.awt.Color(119, 167, 243));
        tripulanteNameTextField.setText("Nome");
        tripulanteNameTextField.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                tripulanteNameTextFieldFocusGained(evt);
            }
            public void focusLost(java.awt.event.FocusEvent evt) {
                tripulanteNameTextFieldFocusLost(evt);
            }
        });

        removeTripulanteLabel.setForeground(new java.awt.Color(255, 255, 255));
        removeTripulanteLabel.setText("Remover");
        removeTripulanteLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                removeTripulanteLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                removeTripulanteLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                removeTripulanteLabelMouseExited(evt);
            }
        });

        saveTripulanteLabel.setForeground(new java.awt.Color(255, 255, 255));
        saveTripulanteLabel.setText("Salvar");
        saveTripulanteLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                saveTripulanteLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                saveTripulanteLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                saveTripulanteLabelMouseExited(evt);
            }
        });

        tripulationTable.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {

            },
            new String [] {
                "Nome", "Cargo"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }
        });
        jScrollPane2.setViewportView(tripulationTable);

        jLabel4.setFont(new java.awt.Font("Lucida Sans", 2, 16));
        jLabel4.setForeground(new java.awt.Color(255, 255, 255));
        jLabel4.setText("Tripulantes");

        cargoComboBox.setForeground(javax.swing.UIManager.getDefaults().getColor("black"));
        cargoComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Piloto", "Copiloto", "Comiss�rio", "Aeromo�a" }));

        updateTripulationTable.setForeground(new java.awt.Color(255, 255, 255));
        updateTripulationTable.setText("Atualizar");
        updateTripulationTable.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                updateTripulationTableMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                updateTripulationTableMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                updateTripulationTableMouseExited(evt);
            }
        });

        org.jdesktop.layout.GroupLayout jPanel3Layout = new org.jdesktop.layout.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jLabel4)
                    .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 368, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel3Layout.createSequentialGroup()
                        .add(saveTripulanteLabel)
                        .add(18, 18, 18)
                        .add(removeTripulanteLabel)
                        .add(18, 18, 18)
                        .add(updateTripulationTable))
                    .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, cargoComboBox, 0, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .add(org.jdesktop.layout.GroupLayout.LEADING, tripulanteNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .add(jLabel4)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(jScrollPane2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 138, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(jPanel3Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
                    .add(saveTripulanteLabel)
                    .add(removeTripulanteLabel)
                    .add(updateTripulationTable))
                .add(18, 18, 18)
                .add(tripulanteNameTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
                .add(cargoComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
                        .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 142, Short.MAX_VALUE)
                        .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(layout.createSequentialGroup()
                .addContainerGap()
                .add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .add(18, 18, 18)
                .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
                    .add(jPanel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                    .add(jPanel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(195, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

private void quitLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitLabelMouseClicked
    main.Return();
    quitLabel.setForeground(Color.white);
}//GEN-LAST:event_quitLabelMouseClicked

private void saveAirplaneLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveAirplaneLabelMouseClicked
    submitAirplane();
}//GEN-LAST:event_saveAirplaneLabelMouseClicked

private void removeAirplaneLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeAirplaneLabelMouseClicked
    removeAirplane();
}//GEN-LAST:event_removeAirplaneLabelMouseClicked

private void updateAirplaneTableLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateAirplaneTableLabelMouseClicked
    updateAirplanesTable();
}//GEN-LAST:event_updateAirplaneTableLabelMouseClicked

private void saveTripulanteLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveTripulanteLabelMouseClicked
    submitTripulante();
}//GEN-LAST:event_saveTripulanteLabelMouseClicked

private void removeTripulanteLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeTripulanteLabelMouseClicked
    removeTripulante();
}//GEN-LAST:event_removeTripulanteLabelMouseClicked

private void updateTripulationTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateTripulationTableMouseClicked
    updateTripulationTable();
}//GEN-LAST:event_updateTripulationTableMouseClicked

private void airplaneIDTextFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_airplaneIDTextFieldFocusGained
    if (airplaneIDTextField.getText().equals(airplaneIDMessage)) {
        TextFieldEffects.activeTextField(airplaneIDTextField);
    }
}//GEN-LAST:event_airplaneIDTextFieldFocusGained

private void airplaneIDTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_airplaneIDTextFieldFocusLost
    if (airplaneIDTextField.getText().equals("")) {
        TextFieldEffects.ociousTextField(airplaneIDTextField, airplaneIDMessage);
    }
}//GEN-LAST:event_airplaneIDTextFieldFocusLost

private void airplaneModelTextFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_airplaneModelTextFieldFocusGained
    if (airplaneModelTextField.getText().equals(airplaneModelMessage)) {
        TextFieldEffects.activeTextField(airplaneModelTextField);
    }
}//GEN-LAST:event_airplaneModelTextFieldFocusGained

private void airplaneModelTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_airplaneModelTextFieldFocusLost
    if (airplaneModelTextField.getText().equals("")) {
        TextFieldEffects.ociousTextField(airplaneModelTextField, airplaneModelMessage);
    }
}//GEN-LAST:event_airplaneModelTextFieldFocusLost

private void tripulanteNameTextFieldFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tripulanteNameTextFieldFocusGained
    if (tripulanteNameTextField.getText().equals(tripulanteNameMessage)) {
        TextFieldEffects.activeTextField(tripulanteNameTextField);
    }
}//GEN-LAST:event_tripulanteNameTextFieldFocusGained

private void tripulanteNameTextFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_tripulanteNameTextFieldFocusLost
    if (tripulanteNameTextField.getText().equals("")) {
        TextFieldEffects.ociousTextField(tripulanteNameTextField, tripulanteNameMessage);
    }
}//GEN-LAST:event_tripulanteNameTextFieldFocusLost

private void saveAirplaneLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveAirplaneLabelMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_saveAirplaneLabelMouseEntered

private void saveAirplaneLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveAirplaneLabelMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_saveAirplaneLabelMouseExited

private void removeAirplaneLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeAirplaneLabelMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_removeAirplaneLabelMouseEntered

private void removeAirplaneLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeAirplaneLabelMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_removeAirplaneLabelMouseExited

private void updateAirplaneTableLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateAirplaneTableLabelMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_updateAirplaneTableLabelMouseEntered

private void updateAirplaneTableLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateAirplaneTableLabelMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_updateAirplaneTableLabelMouseExited

private void saveTripulanteLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveTripulanteLabelMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_saveTripulanteLabelMouseEntered

private void saveTripulanteLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveTripulanteLabelMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_saveTripulanteLabelMouseExited

private void removeTripulanteLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeTripulanteLabelMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_removeTripulanteLabelMouseEntered

private void removeTripulanteLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_removeTripulanteLabelMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_removeTripulanteLabelMouseExited

private void updateTripulationTableMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateTripulationTableMouseEntered
    ((JLabel) evt.getSource()).setForeground(new Color(119, 167, 243));
}//GEN-LAST:event_updateTripulationTableMouseEntered

private void updateTripulationTableMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_updateTripulationTableMouseExited
    ((JLabel) evt.getSource()).setForeground(Color.white);
}//GEN-LAST:event_updateTripulationTableMouseExited

private void quitLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitLabelMouseEntered
    quitLabel.setForeground(new Color(61, 61, 61));
}//GEN-LAST:event_quitLabelMouseEntered

private void quitLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quitLabelMouseExited
    quitLabel.setForeground(Color.white);
}//GEN-LAST:event_quitLabelMouseExited
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JTextField airplaneIDTextField;
    private javax.swing.JTextField airplaneModelTextField;
    private javax.swing.JTable airplanesTable;
    private javax.swing.JComboBox cargoComboBox;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JLabel quitLabel;
    private javax.swing.JLabel removeAirplaneLabel;
    private javax.swing.JLabel removeTripulanteLabel;
    private javax.swing.JLabel saveAirplaneLabel;
    private javax.swing.JLabel saveTripulanteLabel;
    private javax.swing.JLabel titleLabel;
    private javax.swing.JTextField tripulanteNameTextField;
    private javax.swing.JTable tripulationTable;
    private javax.swing.JLabel updateAirplaneTableLabel;
    private javax.swing.JLabel updateTripulationTable;
    // End of variables declaration//GEN-END:variables
    private MainUI main;
    private String airplaneIDMessage = "ID";
    private String airplaneModelMessage = "Modelo";
    private String tripulanteNameMessage = "Nome";
}
